import request from '@/utils/request'
//获取博客列表
export function fetchList(data) {
    return request({
        url: '/blog/posts/page',
        method: 'post',
        data
    })
}
//获取博客
export function edit(params) {
    return request({
        url: '/blog/posts/edit',
        method: 'get',
        params
    })
}
//获取博客
export function view(params) {
    return request({
        url: '/blog/posts/view',
        method: 'get',
        params
    })
}
//获取分类
export function fetchCategory() {
    return request({
        url: '/blog/category/list',
        method: 'get'
    })
}
//获取分类
export function fetchCategoryName() {
    return request({
        url: '/blog/category/name/list',
        method: 'get'
    })
}
//获取友链
export function fetchFriend() {
    return request({
        url: '/blog/friend/site/list',
        method: 'get'
    })
}
//获取社交信息
export function fetchSocial() {
    return request({
        url: '/blog/social/list',
        method: 'get'
    });
}
//获取网站信息
export function fetchSiteInfo() {
    return request({
        url: '/blog/site',
        method: 'get',
        params: {}
    })
}
//获取评论
export function fetchComment(params) {
    return request({
        url: '/blog/comments/list',
        method: 'get',
        params
    })
}

//提交评论
export function submitReply(params) {
    return request({
        url: '/blog/comments/reply/submit',
        method: 'post',
        data: params
    })
}
//留言
export function leaveMessage(params) {
    return request({
        url: '/blog/leave/message',
        method: 'post',
        data: params
    })
}
//发布博客
export function savePost(data) {
    return request({
        url: '/blog/posts/save',
        method: 'post',
        data
    })
}
// //登陆
// export function login(data) {
//     let form = new FormData()
//     let keys = Object.keys(data)
//     keys.forEach(key => {
//         form.append(key, data[key])
//     })
//     return request({
//         url: '/login',
//         method: 'post',
//         headers: {
//             'Content-Type': 'multipart/form-data'
//         },
//         data: form
//     })
// }
//登陆
export function login(data) {
    return request({
        url: '/login',
        method: 'post',
        data
    })
}
//退出登陆
export function logout() {
    return request({
        url: '/logout',
        method: 'get'
    })
}
// 获取验证码
export function getCodeImg() {
    return request({
        url: '/captchaImage',
        method: 'get'
    })
}
// 上传文件
export function uploadFile(formdata) {
    return request({
        url: '/file/upload',
        method: 'post',
        headers: {
            'Content-Type': 'multipart/form-data'
        },
        data: formdata
    })
}
// 下载文件
export function downloadFile(formdata) {
    return request({
        url: '/file/download',
        method: 'get',
        fileId: formdata
    })
}
// 判断是否登录
export function notLogin(formdata) {
    return request({
        url: '/notLogin',
        method: 'get'
    })
}
// 请求后端QQ登录
export function qqLogin(access_token) {
    return request({
        url: '/oauth2/qq/login',
        method: 'post',
        params: { accessToken: access_token }

    })
}
//获取Oauth登录接口信息
export function getOauthLoginInfo(platgorm) {
    return request({
        url: '/oauth2/'+platgorm+'/info',
        method: 'get'
    })
}
//获取Oauth登录接口信息
export function oauth2LoginCallback(platgorm,data) {
    return request({
        url: '/oauth2/callback/'+platgorm,
        method: 'post',
        params:data
    })
}
// 请求后端QQ登录
export function qqCodeLogin(code) {
    return request({
        url: '/oauth2/qq/token',
        method: 'get',
        params: { code: code }
    })
}
// 请求用户信息
export function getUserInfo() {
    return request({
        url: '/user/info',
        method: 'get'
    })
}